﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using twittershared;
namespace send
{
    //rtw1001
    //rtw10011
    /*
     http://help.twitter.com/forums/10711/entries/15364
     * 
     * 
The default rate limit for calls to the REST API is 150 requests per hour. 
 The REST API does account- and IP-based rate limiting. 
 Authenticated API calls are charged to the authenticating user's limit 
  while unauthenticated API calls are deducted from the calling IP address' allotment.     
     
     
     */
    //using rtw;
    class Program
    {

        static void Main(string[] args)
        {
            decimal userid=0;
            az(ref keys.screenName, ref keys.token, ref keys.tokenSecret, ref userid);

          //  useaccount("rtw1001");
         
            //follow("maxgannutin");
        }
       public static void log(string mes)
        {
            Console.WriteLine(mes);
        }
        static void az(ref string screenName, ref  string token, ref string tokenSecret, ref decimal userId)
        {


            var res1 = Twitterizer.OAuthUtility.GetRequestToken(keys.consumerKey, keys.consumerSecret);
            Uri auzUri = Twitterizer.OAuthUtility.BuildAuthorizationUri(res1.Token);
            log(auzUri.AbsoluteUri);
            //авторизоваться через броузер по url'у
            string PIN = "";

            Console.WriteLine("Enter PIN: ");
            PIN = Console.ReadLine();
            var res2 = Twitterizer.OAuthUtility.GetAccessToken(keys.consumerKey, keys.consumerSecret, res1.Token, PIN);
            
            screenName = res2.ScreenName;
            token = res2.Token;
            tokenSecret = res2.TokenSecret;
            userId = res2.UserId;
        }
    }
}
